<?php

defined('BY_JYA') or exit('error');
$cashierid=$this->checklogin();
$_RQ['op']=$_RQ['op']?$_RQ['op']:'index';
if($_RQ['op']=='index'){	
	$return['item']=pdo_get('jy_cashier_user',array('id'=>$cashierid));
	unset($return['item']['password']);
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'edit'=>array(
					array('name'=>'title','title'=>'收银台名称','type'=>'string'),
					array('type'=>'image','title'=>'手机端顶部banner','name'=>'logo'),
					//array('type'=>'radio','title'=>'是否开启分销','name'=>'isopen_commission','options'=>'status'),
					array('name'=>'name','title'=>'联系人','type'=>'string'),
					array('name'=>'mobile','title'=>'联系电话','type'=>'string'),
					array('name'=>'categoryid','title'=>'选择分类','type'=>'select','options'=>'category'),
					array('type'=>'choose','name'=>'mid','title'=>'收款微信号','action'=>'manage.get_member'),
					array('name'=>'username','title'=>'后台登陆账户名','type'=>'string'),
					array('name'=>'password','title'=>'后台登陆密码','type'=>'string'),
					array('type'=>'choose','name'=>'managemid','title'=>'绑定管理员微信号','action'=>'manage.get_member'),
					array('type'=>'choose','name'=>'management','title'=>'手机端管理','action'=>'jy_cashier/manage.get_member/'),
				
		
			)
			);
	
	$return['category']=pdo_getall('jy_cashier_category',array('uniacid'=>$_SESSION['uniacid']),array('id','title'));
	$return['htmls']=$htmls;
	$return['status']=array('0'=>'关闭','1'=>'开启');
	exi($return);
}
if($_RQ['op']=='post'){
	$post=get_postdata();
	$data=array_fields(array('title','logo','isopen_commission','categoryid','name','mobile','username','mid','managemid','management'),$post);
	if($post['password']){
		$data['password']=base64_encode($post['password']);
	}
	pdo_update('jy_cashier_user',$data,array('id'=>$cashierid));
	exi('设置成功！');
}
